/*
 * PyOdeSolver.cpp
 *
 *  Created on: 27 Mar 2012
 *      Author: allan
 */

#include "PyOdeSolver.h"

// GeoReact includes
#include <GeoReact.h>

// Boost includes
#include <boost/python.hpp>
using namespace boost::python;

void export_OdeSolver()
{
	enum_<OdeAlgorithm>("OdeAlgorithm")
        .value("RungeKutta2"                , OdeAlgorithm::RungeKutta2)
        .value("RungeKutta4"                , OdeAlgorithm::RungeKutta4)
        .value("RungeKuttaFehlberg45"       , OdeAlgorithm::RungeKuttaFehlberg45)
        .value("RungeKuttaCashKarp45"       , OdeAlgorithm::RungeKuttaCashKarp45)
        .value("RungeKuttaPrinceDormand8"   , OdeAlgorithm::RungeKuttaPrinceDormand8)
        .value("RungeKuttaImplicitGaussian1", OdeAlgorithm::RungeKuttaImplicitGaussian1)
        .value("RungeKuttaImplicitGaussian2", OdeAlgorithm::RungeKuttaImplicitGaussian2)
        .value("RungeKuttaImplicitGaussian4", OdeAlgorithm::RungeKuttaImplicitGaussian4)
        .value("BulirschStoerImplicit"      , OdeAlgorithm::BulirschStoerImplicit)
        .value("MultistepAdams"             , OdeAlgorithm::MultistepAdams)
        .value("MultistepBDF"               , OdeAlgorithm::MultistepBDF)
        .export_values();
	
	class_<OdeControl>("OdeControl")
        .def_readwrite("eps_abs", &OdeControl::eps_abs)
        .def_readwrite("eps_rel", &OdeControl::eps_rel)
        .def_readwrite("a_y"    , &OdeControl::a_y)
        .def_readwrite("a_dydt" , &OdeControl::a_dydt)
        .def_readwrite("none"   , &OdeControl::none);
	
	class_<OdeSolverParams>("OdeSolverParams")
		.def(init<>())
		.def(init<const OdeAlgorithm&>())
		.def(init<const OdeAlgorithm&, const OdeControl&>())
		
		.def_readwrite("algorithm", &OdeSolverParams::algorithm)
		.def_readwrite("control"  , &OdeSolverParams::control);
	
	class_<OdeSolver>("OdeSolver")
		.def(init<>())
		
		.add_property("parameters",
			make_function(&OdeSolver::GetParameters, return_internal_reference<>()),
			make_function(&OdeSolver::SetParameters));
	
    def("OdeControlNone"      , OdeControlNone);
    def("OdeControlSolution"  , OdeControlSolution);
    def("OdeControlDerivative", OdeControlDerivative);
    def("OdeControlStandard"  , OdeControlStandard);
}

